package com.yu.utils;

import com.mysql.jdbc.PreparedStatement;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Util {
    public static Connection reCon() throws SQLException, ClassNotFoundException {
        Class.forName("com.mysql.jdbc.Driver");
        //2.寤虹珛杩炴帴

        String url = "jdbc:mysql://localhost:3306/ssms?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false";
        String username = "root";
        String password = "root";

        Connection con = DriverManager.getConnection(url, username, password);
        return con;
    }
    public static void closeIO(Connection con, PreparedStatement ps, ResultSet rs) throws Exception{
        if(rs != null) {
            rs.close();
        }
        if(ps != null) {
            ps.close();
        }
        if(con != null) {
            con.close();
        }
    }

    public static void closeConAndPs(Connection con,PreparedStatement ps) throws Exception{

        if(ps != null) {
            ps.close();
        }
        if(con != null) {
            con.close();
        }
    }







}
